import cv2

img = cv2.imread('img/222.jpg')
img = cv2.resize(img, None, fx=1.1, fy=1.1)
#导入人脸数据识别包
faceData = cv2.CascadeClassifier('haarcascade_frontalface_alt.xml')
#对比人脸[[128 42 192 192]] x y w h
#scaleFactor缩放因子，默认值1.3，必须大于1
#minNeighbors临近值
faces = faceData.detectMultiScale(img, scaleFactor=1.05, minNeighbors=5, minSize=(30, 30))
print(faces)
for (x, y, w, h) in faces:
    cv2.rectangle(img, pt1=(x, y), pt2=(x + w, y + h), color=(0, 255, 0), thickness=2)
print(type(img), img.shape)
cv2.imshow('222', img)
cv2.waitKey(0)
cv2.destroyAllWindows()
